import sys
import os

if __name__ == "__main__":
   total_time = int(sys.argv[1])
   cur_cnt = 0
   for cur_cnt in range(total_time):
      if cur_cnt > 0:
         fp = open("test_protocol.txt",'r')
         lines = fp.readlines()
         if str(lines).find('failed(') > 0:
            os.system("mkdir fail_result")
            os.system("xcopy test_protocol.txt fail_result /y")
            break
         else:
            if total_time < 11:
               os.system('move /y unit_test_report.pdf "unit_test_report' + str(cur_cnt) + '.pdf"')
         
      os.system("update_time.bat")
      os.system("execute_unittest.bat")